package cn.thens.kdroid.core.storage

import java.io.File

internal class FileStorageNode(private val file: File) : Storage.Node<ByteArray> {
    override fun get(): ByteArray {
        return file.inputStream().use { it.readBytes() }
    }

    override fun put(value: ByteArray) {
        return file.outputStream().use { it.write(value) }
    }

    override fun clear() {
        file.delete()
    }

    override fun exists(): Boolean {
        return file.exists()
    }
}
